import React from 'react';
import {BrowserRouter as Router, Route, Switch, withRouter} from 'react-router-dom';
import {Button} from 'antd';
import Room from './Room';
import Login from './Login';

function App(props) {
  return (
    <div>
      <Router history={props.history}>
        <Switch>
          <Route path="/login" component={Login}/>
          <Route path="/room" component={Room}/>
          <Operate />
        </Switch>
      </Router>
    </div>
  );
}

const Operate = withRouter((props) => {
  const {history} = props;
  return (
    <div>
      <Button type="primary" onClick={()=>{history.push('/login')}}>登录</Button>
      <Button type="primary" onClick={()=>{history.push('/room')}}>聊天室</Button>
    </div>
  )
})

export default App;
